// 引入依赖
import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'

// vue添加router功能
Vue.use(Router)

// 生成路由，main.js注册
// 将路由映射到组件
export default new Router({
  routes: [
    {
      path: '/hello',
      name: 'HelloWorld',
      component: HelloWorld
    },
    {
      name: 'head',
      path: '/head',
      component: () => import('@/views/app/head'),
      meta: {
        title: '商城head'
      }
    },
    {
      name: 'footer',
      path: '/footer',
      component: () => import('@/views/app/footer'),
      meta: {
        title: '商城 footer'
      }
    },
    {
      name: 'slide',
      path: '/slide',
      component: () => import('@/views/index/slide'),
      meta: {
        title: 'slide页面'
      }
    },
    {
      name: 'recommend',
      path: '/recommend',
      component: () => import('@/views/index/recommend'),
      meta: {
        title: 'slide页面'
      }
    },
    {
      name: 'categorygoods',
      path: '/categorygoods',
      component: () => import('@/views/index/categorygoods'),
      meta: {
        title: 'slide页面'
      }
    },
    {
      name: 'list',
      path: '/list/:id',
      component: () => import('@/views/list/list'),
      meta: {
        title: '商品列表'
      }
    },
    {
      name: 'detail',
      path: '/detail/:id',
      component: () => import('@/views/detail/detail'),
      meta: {
        title: '明细页'
      }
    },
    {
      name: 'index',
      path: '/index/:id',
      component: () => import('@/views/index/index'),
      meta: {
        title: '明细页'
      }
    },
    {
      name: 'index',
      path: '/index',
      component: () => import('@/views/index/index'),
      meta: {
        title: '商城首页'
      }
    },
    {
      name: 'reg',
      path: '/reg',
      component: () => import('@/views/user/reg'),
      meta: {
        title: '用户注册'
      }
    },
    {
      name: 'login',
      path: '/login',
      component: () => import('@/views/user/login'),
      meta: {
        title: '用户登录'
      }
    },
    {
      name: 'cart',
      path: '/cart',
      component: () => import('@/views/cart/cart'),
      meta: {
        title: '购物车'
      }
    },
    {
      name: 'checkout',
      path: '/checkout',
      component: () => import('@/views/cart/checkout'),
      meta: {
        title: '结算'
      }
    },
    {
      name: 'address',
      path: '/address',
      component: () => import('@/views/user/address'),
      meta: {
        title: '我的配送地址'
      }
    },
    {
      name: 'profile',
      path: '/profile',
      component: () => import('@/views/user/profile'),
      meta: {
        title: '个人中心'
      }
    },
    {
      name: '/myorder',
      path: '/myorder',
      component: () => import('@/views/user/myorder'),
      meta: {
        title: '我的订单'
      }
    }
  ]
})
